import UIKit
import SnapKit

class PlaceholderCardView: UIView {
    let label = UILabel()
    private var word:String?
    
    override init(frame: CGRect) { super.init(frame: frame); setup() }
    required init?(coder: NSCoder) { super.init(coder: coder); setup() }
    
    private func setup() {
//        backgroundColor = UIColor(white: 0.12, alpha: 1)
        layer.cornerRadius = 10
        layer.borderWidth = 2
        layer.borderColor = UIColor.clear.cgColor
        label.font = UIFont.boldSystemFont(ofSize: 28)
        label.textColor = .white
        label.numberOfLines = 0
        label.textAlignment = .center
        addSubview(label)
        label.snp.makeConstraints { make in make.center.equalToSuperview() }
    }
    func setHighlighted(_ yes: Bool) {
        layer.borderColor = yes ? UIColor.systemBlue.cgColor : UIColor.clear.cgColor
    }
    
    public func getWord()->String{
        return self.word ?? ""
    }
    
    func setWord(_ word: String?) {
        self.word = word
        label.isHidden = word == nil
        label.text = word
        setHighlighted(false)
        let txt = word ?? ""
        backgroundColor = txt.isEmpty ? UIColor(white: 0.12, alpha: 1) :  Colors.yellow
    }
}
